﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AD.Model;
using AD.BLL;

public partial class Manager_User_PageData_ChangePass : WebManagerForm
{
    public ManagerUserMod user = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        //user = Session[UtilHepler.SESSION_NAME] as ManagerUserMod;
        user = UtilHepler.GetMangerClientCookies(Request, Response);
        if (Page.IsPostBack && user!=null)
        {
            string oldpass = Request.Params["oldpass"];
            string pass = Request.Params["pass"];
            string pass2 = Request.Params["pass2"];
            if (string.IsNullOrEmpty(oldpass))
            {
                Alert("旧密码不能为空！");
                return;
            }
            if (string.IsNullOrEmpty(pass))
            {
                Alert("密码不能为空！");
                return;
            }
            if (!pass.Equals(pass2))
            {
                Alert("两次密码输入不一致！");
                return;
            }
            if (user.Passwd.Equals(oldpass))
            {
                int effect = ManagerUserBLL.Update(new ManagerUserMod() { AutoID = user.AutoID, UserName = user.UserName, Passwd = pass, IsValid = user.IsValid });
                if (effect > 0)
                {
                    Alert("管理用户密码修改成功!");
                }
                else
                {
                    Alert("管理用户密码修改失败!");
                }
            }
            else
            {
                Alert("管理用户密码不正确!请重新输入正确密码!");
            }
        }
    }
}